package com.magnificent.atlantis.client.robot.ui.configure;

import com.magnificent.atlantis.client.robot.RobotContext;
import com.magnificent.atlantis.client.robot.strategies.RobotStrategy;
import com.magnificent.atlantis.common.entity.ServerUser;
import com.magnificent.commons.utils.collections.list.MetaList;

/**
 * User: Babanin
 * Date: Aug 29, 2009
 * Time: 2:39:09 AM
 */
public class RobotConfiguration {
    private int port;
    private String host;
    private ServerUser user;
    private MetaList<ServerUser> otherUsers;

    private RobotStrategy strategy;
    private boolean activated;

    private int dayPeriod;
    private int workDayStart;
    private int workDayFinish;

    public RobotConfiguration() {
        dayPeriod = 5;
        workDayStart = 9;
        workDayFinish = 18;
    }

    public ServerUser getUser() {
        return user;
    }

    public void setUser(ServerUser user) {
        this.user = user;
    }

    public RobotStrategy getStrategy() {
        return strategy;
    }

    public void setStrategy(RobotStrategy strategy) {
        this.strategy = strategy;
    }

    public boolean isActivated() {
        return activated;
    }

    public void setActivated(boolean activated) {
        this.activated = activated;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public MetaList<ServerUser> getOtherUsers() {
        return otherUsers;
    }

    public void setOtherUsers(MetaList<ServerUser> otherUsers) {
        this.otherUsers = otherUsers;
    }

    public int getDayPeriod() {
        return dayPeriod;
    }

    public void setDayPeriod(int dayPeriod) {
        this.dayPeriod = dayPeriod;
    }

    public int getWorkDayStart() {
        return workDayStart;
    }

    public void setWorkDayStart(int workDayStart) {
        this.workDayStart = workDayStart;
    }

    public int getWorkDayFinish() {
        return workDayFinish;
    }

    public void setWorkDayFinish(int workDayFinish) {
        this.workDayFinish = workDayFinish;
    }

    @Override
    public String toString() {
        return "[Login = " + user.getLogin() + "] [Strategy = " +
                strategy.toString() + "] [Activated = " + activated + "]";
    }

    public RobotContext toRobotContext() {
        RobotContext robotContext = new RobotContext(user.getLogin(), user.getClearPassword());

        robotContext.setUsers(otherUsers);
        robotContext.setDayPeriod(dayPeriod);
        robotContext.setWorkDayStart(workDayStart);
        robotContext.setWorkDayFinish(workDayFinish);

        return robotContext;
    }
}
